package com.nervenets.shopping.hibernate.domain.user;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.nervenets.general.hibernate.DomainObject;
import com.nervenets.shopping.enumeration.Gender;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.SuperBuilder;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * 管理人员
 */
@Entity
@Table
@Setter
@Getter
@AllArgsConstructor
@NoArgsConstructor
@SuperBuilder
public class Manager extends DomainObject {
    @ApiModelProperty(value = "账号")
    @org.hibernate.annotations.Index(name = "_idx_manager_mobile")
    @Column(columnDefinition = "varchar(20)")
    private String mobile;
    @ApiModelProperty(value = "密码")
    @Column(columnDefinition = "varchar(20)")
    @JsonIgnore
    @JSONField(serialize = false)
    private String password;
    @ApiModelProperty(value = "昵称")
    @Column(columnDefinition = "varchar(20)")
    private String name;
    @ApiModelProperty(value = "头像")
    private String avatar;
    @ManyToMany
    @JoinTable(
            name = "manager_of_role",
            joinColumns = {@JoinColumn(name = "manager_id", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "role_id", referencedColumnName = "id")}
    )
    private List<RoleGroup> roleGroups = new ArrayList<>();
    @Builder.Default
    @ApiModelProperty(value = "性别")
    @Column(columnDefinition = "tinyint")
    private Gender gender = Gender.female;
    @Builder.Default
    @ApiModelProperty(value = "是否启用")
    private boolean enable = true;
}
